//
//  ReaderMenuAnimation.m
//  UIDynamic
//
//  Created by pro1 on 2019/1/5.
//  Copyright © 2019 pro1. All rights reserved.
//

#import "MenuAnimation.h"

@implementation MenuAnimation

+ (void)HiddenAnimation:(UIView *)view completion:(void(^)(BOOL finished))completion{
    CGRect frame = view.frame;
    if (view.frame.origin.y == 0) {
        //顶部菜单
        frame.origin.y = view.frame.size.height;
    }
    else if (view.frame.origin.y == [UIScreen mainScreen].bounds.size.height - view.frame.size.height){
        //底部菜单
        frame.origin.y = -[UIScreen mainScreen].bounds.size.height;
    }
    [UIView animateWithDuration:0.2 animations:^{
        view.frame = frame;
    } completion:^(BOOL finished) {
        
        if (completion) {
            completion(finished);
        }
    }];
}
+ (void)ShowAnimation:(UIView *)view completion:(void(^)(BOOL finished))completion{
    CGRect frame = view.frame;
    if (view.frame.origin.y < 0) {
        //顶部菜单
        frame.origin.y = 0;
    }
    else if (view.frame.origin.y >= [UIScreen mainScreen].bounds.size.height){
        //底部菜单
        frame.origin.y = [UIScreen mainScreen].bounds.size.height - view.frame.size.height;
    }
    [UIView animateWithDuration:0.2 animations:^{
        view.frame = frame;
    } completion:^(BOOL finished) {
        if (completion) {
            completion(finished);
        }
    }];
}

@end
